package Thread.Demo5Lambda;

/**
 * @Author wangzhipeng
 * @Date 2020-08-10 3:24 下午
 * @Description
 */
public class TestLambda {

    //静态内部类
    static class Like2 implements ILike{
        public void lambda() {
            System.out.println("I Like Lambda2");
        }
    }


    public static void main(String[] args) {
        ILike like = new Like();//第一种方法 普通方法
        like.lambda();

        like = new Like2();// 第二种方法 静态内部类
        like.lambda();

        //局部内部类
        class Like3 implements ILike{
            public void lambda() {
                System.out.println("I Like Lambda3");
            }
        }


        like = new Like3();
        like.lambda();


        //匿名内部类
        like = new ILike() {
            public void lambda() {
                System.out.println("I Like Lambda4");
            }
        };
        like.lambda();

        //用lambad再次简化
        like = ()->{
            System.out.println("I Like Lambda5");
        };
        like.lambda();


    }
}

interface  ILike{
    void lambda();
}

class Like implements ILike{
    public void lambda() {
        System.out.println("I Like Lambda");
    }
}

